/*
 *  Car.h
 *  Copyright 2008 . All rights reserved.
 */

#import <Foundation/Foundation.h>
#import <sqlite3.h>

@interface Car : NSObject {
    sqlite3 *database;
    int pk;
    NSString *label;
	float start;
	BOOL selected;

    // Dirty tracks whether there are in-memory changes to data which have no been written to the database.
    BOOL dirty;
}

@property (nonatomic) sqlite3 *database;
@property (nonatomic) int pk;
@property (nonatomic, copy) NSString *label;
@property (nonatomic) float start;
@property (nonatomic) BOOL selected;
@property (nonatomic) BOOL dirty;

// Finalize (delete) all of the SQLite compiled queries.
+ (void)finalizeStatements;
// Get all cars
+ (void)getAll:(NSMutableArray *)output database:(sqlite3 *)db;

- (id)init;
// Creates the object with primary key and title is brought into memory.
- (id)initWithPrimaryKey:(int)key database:(sqlite3 *)db;
// Inserts the car into the database and stores its primary key.
- (void)insertIntoDatabase:(sqlite3 *)database;
// Save data
- (void)updateDatabase;
// Remove the car complete from the database. In memory deletion to follow...
- (void)deleteFromDatabase;

@end

